package uit.comstore.model.blo;

import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;
import uit.comstore.model.entity.Delivery;
import uit.comstore.utils.HibernateSessionFactory;

public class DeliveryBLO {
	@SuppressWarnings("unchecked")
	public List<Delivery> list() {
		List<Delivery> deliveries = null;
		Session session = HibernateSessionFactory.getSessionFactory().getCurrentSession();
		session.beginTransaction();
		Query query = session.createQuery("from Delivery");
		deliveries = query.list();
		session.getTransaction().commit();
		return deliveries;
	}
	
	public Delivery add(Delivery delivery) {
		Session session = HibernateSessionFactory.getSessionFactory().getCurrentSession();
		session.beginTransaction();
		session.save(delivery);
		session.getTransaction().commit();
		return delivery;
	}
}
